$(function () {
    $("#index_tabs").tabs({
        tabHeight: '50',
        plain: false
    });
    $("#index_tree").tree({
        url: "/systemMenu/queryRootMenu",
        onClick: function (node) {
            var isLeaf = $("#index_tree").tree("isLeaf", node.target);
            if (!isLeaf) {
                return;
            }
            //模块 + 文本确定唯一
            var text;
            var parent = node.parent.text;
            if (parent) {
                text = parent + ">" + node.text;
            } else {
                text = node.text;
            }
            var exists = $("#index_tabs").tabs("exists", text);
            var url = node.url;
            if (exists) {
                $("#index_tabs").tabs("select", text);
            } else {
                $("#index_tabs").tabs("add", {
                    title: text,
                    content: "<iframe style='border: 0;' frameborder='false' width='98%' height='98%' src=" + url + "></iframe>",
                    closable: true,
                    border: false
                });
                //$("#index_tabs div").addClass("look_background");
                //$("#index_tabs").removeClass("look_background");
            }
        },
        onLoadSuccess: function (node, data) {
            $("#index_tree").tree("collapseAll", data.target);
            console.log(data);
            //$("#index_tree").remove
            $(".tree-icon").removeClass();
            var closestLi = $(".tree-title").closest("li");
            $(".tree-node").addClass("change_height");
        }
    });

    //$(".tree-icon").removeClass("tree-icon");
    //console.log($(".tree-icon"));
    //$("#index_tree").tree("collapseAll");
    //$(".accordion-header").addClass("bg_color");
    /*$(".accordion-header").click(function(){
     if($(this).hasClass("accordion-header-selected")) {
     $(".accordion-header").removeClass("change_select_accordion_color");
     $(this).addClass("change_select_accordion_color");
     $(this).find("div").addClass("change_select_accordion_color");
     }else{
     $(this).find("div").removeClass("change_select_accordion_color");
     }
     });*/


    $("#index_dialog").dialog({
        width: 400,
        height: 120,
        closed: true
    });

});
//begin签到按钮功能
function signIn() {
    $.get('/attence/signIn', function (date) {
        if (date.success) {
            $.messager.alert('温馨提示', '签到成功');
        } else {
            $.messager.alert('温馨提示', date.msg);
        }
    })

}
//end签到按钮功能

//begin签退按钮功能
function signout() {
    $.get('/attence/signOut', function (date) {
        if (date.success) {
            $.messager.alert('温馨提示', '签退成功');
        } else {
            $.messager.alert('温馨提示', date.msg);
        }
    })
}
//end签退按钮功能
function logout() {
    window.location.href = "/logout";
}

$(function (){
   $.get("/employee/getCurrentEmployee",function (data) {
       /*var text = "入职时间:" + data.inputTime;
       $("#getCurrentEmployee").html(text);*/
       //console.log(data);
       var content = "<div style='text-align: center;font-family: 楷体;font-size: 20px;'><table>"
               + "<tr><td>姓名</td><td>" + data.username
               + "</td></tr><tr><td>年龄</td><td>" + data.age
               + "</td></tr><tr><td>电话</td><td>" + data.tel
               + "</td></tr><tr><td>邮件</td><td>" + data.email
               + "</td></tr><tr><td>性别</td><td>" + data.gender
               + "</td></tr><tr><td>生日</td><td>" + data.birthTime
               + "</td></tr><tr><td>入职时间</td><td>" + data.inputTime
               + "</td></tr><tr><td>工龄</td><td>" + data.serviceLength
               + "</td></tr><tr><td>婚否</td><td>" + data.marital
               + "</td></tr><tr><td>地址</td><td>" + data.address
           + "</td></table></div>";
       $("#message").dialog({
           title: '个人信息',
           width: 250,
           height: 280,
           closed: true,
           //lock:true,
           modal:true,
           content:content
       });

       //系统检测到你未婚,要不要给你介绍对象啊
       if(data){
           if(data.marital == '未婚'){
               window.setTimeout(marital,10000);
           }
       }
   });

    $("#btn_message").click(function(){
        $("#message").dialog("open");
    });

});

function marital() {
    var text = "<font face='楷体' color='#1e90ff' size='5'>您当前是未婚状态,要不要给您介绍一个对象啊???</font>";
    $.messager.alert('程序员',text);
}


function lockscreen(){

    $("#index_dialog").dialog("open");


}

function unlockSubmit(){
    $("#lock_form").form('submit',{

        url:'/employee/deblocking',
        success:function(data){
            data=$.parseJSON(data);
            console.log(data)
            if(data.success){
                $("#index_dialog").dialog("close");
                $("#lock_form").form('clear')
            }else{
                $.messager.alert('警告',data.msg);
            }
        }
    })
}







